﻿using System;
using System.Data;
using System.Text;
using System.Data.OracleClient;
using DBUtility;//Please add references
namespace TierApplication
{
	/// <summary>
	/// 类T_ORDER。
	/// </summary>
	[Serializable]
	public partial class T_ORDER
	{
		public T_ORDER()
		{}
		#region Model
		private string _orderid;
		private DateTime? _orderdate;
		private string _accountid;
		private string _orderstatus;
		private DateTime? _paydate;
		private decimal? _totalfee;
		private DateTime? _canceldate;
		private string _cancelreason;
		private decimal? _totalpoint;
		private string _remark;
		/// <summary>
		/// 订单编号
		/// </summary>
		public string ORDERID
		{
			set{ _orderid=value;}
			get{return _orderid;}
		}
		/// <summary>
		/// 下单日期
		/// </summary>
		public DateTime? ORDERDATE
		{
			set{ _orderdate=value;}
			get{return _orderdate;}
		}
		/// <summary>
		/// 用户账号
		/// </summary>
		public string ACCOUNTID
		{
			set{ _accountid=value;}
			get{return _accountid;}
		}
		/// <summary>
		/// 订单状态 C_OrderStatus
		/// </summary>
		public string ORDERSTATUS
		{
			set{ _orderstatus=value;}
			get{return _orderstatus;}
		}
		/// <summary>
		/// 付款完成日期
		/// </summary>
		public DateTime? PAYDATE
		{
			set{ _paydate=value;}
			get{return _paydate;}
		}
		/// <summary>
		/// 总金额
		/// </summary>
		public decimal? TOTALFEE
		{
			set{ _totalfee=value;}
			get{return _totalfee;}
		}
		/// <summary>
		/// 取消日期
		/// </summary>
		public DateTime? CANCELDATE
		{
			set{ _canceldate=value;}
			get{return _canceldate;}
		}
		/// <summary>
		/// 取消原因 C_CancelReason
		/// </summary>
		public string CANCELREASON
		{
			set{ _cancelreason=value;}
			get{return _cancelreason;}
		}
		/// <summary>
		/// 订单积分
		/// </summary>
		public decimal? TOTALPOINT
		{
			set{ _totalpoint=value;}
			get{return _totalpoint;}
		}
		/// <summary>
		/// 备注
		/// </summary>
		public string REMARK
		{
			set{ _remark=value;}
			get{return _remark;}
		}
		#endregion Model


		#region  Method

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public T_ORDER(string ORDERID)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ORDERID,ORDERDATE,ACCOUNTID,ORDERSTATUS,PAYDATE,TOTALFEE,CANCELDATE,CANCELREASON,TOTALPOINT,REMARK ");
			strSql.Append(" FROM T_ORDER ");
			strSql.Append(" where ORDERID=:ORDERID ");
			OracleParameter[] parameters = {
					new OracleParameter(":ORDERID", OracleType.VarChar,50)};
			parameters[0].Value = ORDERID;

			DataSet ds=DbHelperOra.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				if(ds.Tables[0].Rows[0]["ORDERID"]!=null && ds.Tables[0].Rows[0]["ORDERID"].ToString()!="")
				{
					this.ORDERID=ds.Tables[0].Rows[0]["ORDERID"].ToString();
				}
				if(ds.Tables[0].Rows[0]["ORDERDATE"]!=null && ds.Tables[0].Rows[0]["ORDERDATE"].ToString()!="")
				{
					this.ORDERDATE=DateTime.Parse(ds.Tables[0].Rows[0]["ORDERDATE"].ToString());
				}
				if(ds.Tables[0].Rows[0]["ACCOUNTID"]!=null && ds.Tables[0].Rows[0]["ACCOUNTID"].ToString()!="")
				{
					this.ACCOUNTID=ds.Tables[0].Rows[0]["ACCOUNTID"].ToString();
				}
				if(ds.Tables[0].Rows[0]["ORDERSTATUS"]!=null && ds.Tables[0].Rows[0]["ORDERSTATUS"].ToString()!="")
				{
					this.ORDERSTATUS=ds.Tables[0].Rows[0]["ORDERSTATUS"].ToString();
				}
				if(ds.Tables[0].Rows[0]["PAYDATE"]!=null && ds.Tables[0].Rows[0]["PAYDATE"].ToString()!="")
				{
					this.PAYDATE=DateTime.Parse(ds.Tables[0].Rows[0]["PAYDATE"].ToString());
				}
				if(ds.Tables[0].Rows[0]["TOTALFEE"]!=null && ds.Tables[0].Rows[0]["TOTALFEE"].ToString()!="")
				{
					this.TOTALFEE=decimal.Parse(ds.Tables[0].Rows[0]["TOTALFEE"].ToString());
				}
				if(ds.Tables[0].Rows[0]["CANCELDATE"]!=null && ds.Tables[0].Rows[0]["CANCELDATE"].ToString()!="")
				{
					this.CANCELDATE=DateTime.Parse(ds.Tables[0].Rows[0]["CANCELDATE"].ToString());
				}
				if(ds.Tables[0].Rows[0]["CANCELREASON"]!=null && ds.Tables[0].Rows[0]["CANCELREASON"].ToString()!="")
				{
					this.CANCELREASON=ds.Tables[0].Rows[0]["CANCELREASON"].ToString();
				}
				if(ds.Tables[0].Rows[0]["TOTALPOINT"]!=null && ds.Tables[0].Rows[0]["TOTALPOINT"].ToString()!="")
				{
					this.TOTALPOINT=decimal.Parse(ds.Tables[0].Rows[0]["TOTALPOINT"].ToString());
				}
				if(ds.Tables[0].Rows[0]["REMARK"]!=null && ds.Tables[0].Rows[0]["REMARK"].ToString()!="")
				{
					this.REMARK=ds.Tables[0].Rows[0]["REMARK"].ToString();
				}
			}
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(string ORDERID)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) from T_ORDER");
			strSql.Append(" where ORDERID=:ORDERID ");

			OracleParameter[] parameters = {
					new OracleParameter(":ORDERID", OracleType.VarChar,50)};
			parameters[0].Value = ORDERID;

			return DbHelperOra.Exists(strSql.ToString(),parameters);
		}


		/// <summary>
		/// 增加一条数据
		/// </summary>
		public void Add()
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into T_ORDER (");
			strSql.Append("ORDERID,ORDERDATE,ACCOUNTID,ORDERSTATUS,PAYDATE,TOTALFEE,CANCELDATE,CANCELREASON,TOTALPOINT,REMARK)");
			strSql.Append(" values (");
			strSql.Append(":ORDERID,:ORDERDATE,:ACCOUNTID,:ORDERSTATUS,:PAYDATE,:TOTALFEE,:CANCELDATE,:CANCELREASON,:TOTALPOINT,:REMARK)");
			OracleParameter[] parameters = {
					new OracleParameter(":ORDERID", OracleType.VarChar,10),
					new OracleParameter(":ORDERDATE", OracleType.DateTime),
					new OracleParameter(":ACCOUNTID", OracleType.VarChar,20),
					new OracleParameter(":ORDERSTATUS", OracleType.VarChar,1),
					new OracleParameter(":PAYDATE", OracleType.DateTime),
					new OracleParameter(":TOTALFEE", OracleType.Number,12),
					new OracleParameter(":CANCELDATE", OracleType.DateTime),
					new OracleParameter(":CANCELREASON", OracleType.VarChar,1),
					new OracleParameter(":TOTALPOINT", OracleType.Number,12),
					new OracleParameter(":REMARK", OracleType.VarChar,250)};
			parameters[0].Value = ORDERID;
			parameters[1].Value = ORDERDATE;
			parameters[2].Value = ACCOUNTID;
			parameters[3].Value = ORDERSTATUS;
			parameters[4].Value = PAYDATE;
			parameters[5].Value = TOTALFEE;
			parameters[6].Value = CANCELDATE;
			parameters[7].Value = CANCELREASON;
			parameters[8].Value = TOTALPOINT;
			parameters[9].Value = REMARK;

			DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update()
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update T_ORDER set ");
			strSql.Append("ORDERDATE=:ORDERDATE,");
			strSql.Append("ACCOUNTID=:ACCOUNTID,");
			strSql.Append("ORDERSTATUS=:ORDERSTATUS,");
			strSql.Append("PAYDATE=:PAYDATE,");
			strSql.Append("TOTALFEE=:TOTALFEE,");
			strSql.Append("CANCELDATE=:CANCELDATE,");
			strSql.Append("CANCELREASON=:CANCELREASON,");
			strSql.Append("TOTALPOINT=:TOTALPOINT,");
			strSql.Append("REMARK=:REMARK");
			strSql.Append(" where ORDERID=:ORDERID ");
			OracleParameter[] parameters = {
					new OracleParameter(":ORDERDATE", OracleType.DateTime),
					new OracleParameter(":ACCOUNTID", OracleType.VarChar,20),
					new OracleParameter(":ORDERSTATUS", OracleType.VarChar,1),
					new OracleParameter(":PAYDATE", OracleType.DateTime),
					new OracleParameter(":TOTALFEE", OracleType.Number,12),
					new OracleParameter(":CANCELDATE", OracleType.DateTime),
					new OracleParameter(":CANCELREASON", OracleType.VarChar,1),
					new OracleParameter(":TOTALPOINT", OracleType.Number,12),
					new OracleParameter(":REMARK", OracleType.VarChar,250),
					new OracleParameter(":ORDERID", OracleType.VarChar,10)};
			parameters[0].Value = ORDERDATE;
			parameters[1].Value = ACCOUNTID;
			parameters[2].Value = ORDERSTATUS;
			parameters[3].Value = PAYDATE;
			parameters[4].Value = TOTALFEE;
			parameters[5].Value = CANCELDATE;
			parameters[6].Value = CANCELREASON;
			parameters[7].Value = TOTALPOINT;
			parameters[8].Value = REMARK;
			parameters[9].Value = ORDERID;

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(string ORDERID)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from T_ORDER ");
			strSql.Append(" where ORDERID=:ORDERID ");
			OracleParameter[] parameters = {
					new OracleParameter(":ORDERID", OracleType.VarChar,50)};
			parameters[0].Value = ORDERID;

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public void GetModel(string ORDERID)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ORDERID,ORDERDATE,ACCOUNTID,ORDERSTATUS,PAYDATE,TOTALFEE,CANCELDATE,CANCELREASON,TOTALPOINT,REMARK ");
			strSql.Append(" FROM T_ORDER ");
			strSql.Append(" where ORDERID=:ORDERID ");
			OracleParameter[] parameters = {
					new OracleParameter(":ORDERID", OracleType.VarChar,50)};
			parameters[0].Value = ORDERID;

			DataSet ds=DbHelperOra.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				if(ds.Tables[0].Rows[0]["ORDERID"]!=null && ds.Tables[0].Rows[0]["ORDERID"].ToString()!="")
				{
					this.ORDERID=ds.Tables[0].Rows[0]["ORDERID"].ToString();
				}
				if(ds.Tables[0].Rows[0]["ORDERDATE"]!=null && ds.Tables[0].Rows[0]["ORDERDATE"].ToString()!="")
				{
					this.ORDERDATE=DateTime.Parse(ds.Tables[0].Rows[0]["ORDERDATE"].ToString());
				}
				if(ds.Tables[0].Rows[0]["ACCOUNTID"]!=null && ds.Tables[0].Rows[0]["ACCOUNTID"].ToString()!="")
				{
					this.ACCOUNTID=ds.Tables[0].Rows[0]["ACCOUNTID"].ToString();
				}
				if(ds.Tables[0].Rows[0]["ORDERSTATUS"]!=null && ds.Tables[0].Rows[0]["ORDERSTATUS"].ToString()!="")
				{
					this.ORDERSTATUS=ds.Tables[0].Rows[0]["ORDERSTATUS"].ToString();
				}
				if(ds.Tables[0].Rows[0]["PAYDATE"]!=null && ds.Tables[0].Rows[0]["PAYDATE"].ToString()!="")
				{
					this.PAYDATE=DateTime.Parse(ds.Tables[0].Rows[0]["PAYDATE"].ToString());
				}
				if(ds.Tables[0].Rows[0]["TOTALFEE"]!=null && ds.Tables[0].Rows[0]["TOTALFEE"].ToString()!="")
				{
					this.TOTALFEE=decimal.Parse(ds.Tables[0].Rows[0]["TOTALFEE"].ToString());
				}
				if(ds.Tables[0].Rows[0]["CANCELDATE"]!=null && ds.Tables[0].Rows[0]["CANCELDATE"].ToString()!="")
				{
					this.CANCELDATE=DateTime.Parse(ds.Tables[0].Rows[0]["CANCELDATE"].ToString());
				}
				if(ds.Tables[0].Rows[0]["CANCELREASON"]!=null && ds.Tables[0].Rows[0]["CANCELREASON"].ToString()!="")
				{
					this.CANCELREASON=ds.Tables[0].Rows[0]["CANCELREASON"].ToString();
				}
				if(ds.Tables[0].Rows[0]["TOTALPOINT"]!=null && ds.Tables[0].Rows[0]["TOTALPOINT"].ToString()!="")
				{
					this.TOTALPOINT=decimal.Parse(ds.Tables[0].Rows[0]["TOTALPOINT"].ToString());
				}
				if(ds.Tables[0].Rows[0]["REMARK"]!=null && ds.Tables[0].Rows[0]["REMARK"].ToString()!="")
				{
					this.REMARK=ds.Tables[0].Rows[0]["REMARK"].ToString();
				}
			}
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select * ");
			strSql.Append(" FROM T_ORDER ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperOra.Query(strSql.ToString());
		}

		#endregion  Method
	}
}

